


local console = ac.console
local buttons = {}
for i,panel in ipairs(console.abilitydetail) do
    local button = panel:add(class.skill_button,'1')
    button.column = (i-1) % 4
    button.row = (i-1) // 4 
    button.key1 = button:add_panel([[textures\black32.blp]],2,2,20,20)
    button.key2 = button.key1:add_text('A',2,2,0,20,12,5)
    panel.effect_button = button

    table.insert(buttons,button)
end

local message = require 'jass.message'
ac.hardware:event '界面绘制'(function()
    local unit = ac.unit(japi.GetRealSelectUnit())
    for _,button in ipairs(buttons) do
        local ability_id, order_id = message.button(button.column,button.row)
        local skill = ac.lni("commandbuttons", tostring(order_id))
        if unit and skill==nil and unit.play_skills and ability_id then 
            skill = unit.play_skills[ability_id]
            button:refresh(skill)
        else
            button:refresh()
        end

        local hotkey = skill and (skill.hotkey or skill:get_hotkey())
        if hotkey and skill.skill_type~='passive' then
            button.key2:set_text(hotkey)
            button.key1:set_width(button.key2:get_width()+6)
            button.key1:show()
        else
            button.key1:hide()
        end
    end
end)

return panel
